package com.heima.behavior;

import com.heima.behavior.pojos.ApComment;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.MongoTemplate;

@SpringBootTest
public class Apcommentext {
    @Autowired
    MongoTemplate mongoTemplate;

    @Test
    public void testAdd() throws Exception{
        for (int i = 0; i < 10; i++) {
            ApComment apComment = new ApComment();
            //        apComment.setId("2222");
            apComment.setAddress("上海");
            apComment.setContent("上海是一个好地方222"+i);
            apComment.setLikes(2+i);
            // 60c2fe86c5a9e6651633a54a  ObjectId
            //        ApComment comment = mongoTemplate.insert(apComment);
            ApComment comment = mongoTemplate.save(apComment);
            System.out.println(comment);
        }
    }
}
